package com.example.study.mqtt.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * 建立MQTT服务端连接工具类MqttConfig，用于加载配置参数
 * #  host: tcp://localhost:1883
 * #  #MQTT-服务端用户名
 * #  username: admin
 * #  #MQTT-服务端密码
 * #  password: public
 * #  #MQTT-是否清理session
 * #  cleansession: false
 * #  #MQTT-当前客户端的唯一标识
 * #  clientid: mqtt_publish
 * #  #当前客户端的默认主题(大多数时候没什么用)
 * #  default_topic: 测试
 * #  #发送超时时间
 * #  timeout: 1000
 * #  #心跳时间
 * #  keepalive: 10
 * #  #连接超时时间
 * #  connectionTimeout: 3000
 * <p>
 * <p>
 * 使用MQTT 协议默认的交换机 Exchange 为 amp.topic，
 * 而我们订阅的主题会在 Queues 注册一个客户端队列，路由 Routing key 就是我们设置的主题。
 */
@Component
//@ConfigurationProperties(MQTTConfig.PREFIX)
public class MQTTConfig {
    //指定配置文件application-local.properties中的属性名前缀
    public static final String PREFIX = "mqtt";
    @Value("${constant.host}")
    private String serviceHost;

    private String host = "tcp://8.130.21.209:1883";
    private String publish_clientId = "发消息";
    private String subscribe_clientId = "收消息";
    private String username = "lufei";
    private String password = "6418019";
    private boolean cleansession = true;
    private String default_topic = "测试";
    private int timeout = 1000;
    private int keepalive = 10;
    private int connectionTimeout = 3000;

    public String getHost() {
        return "tcp://"+"8.130.21.209"+":1883";
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPublish_clientId() {
        return publish_clientId;
    }

    public void setPublish_clientId(String publish_clientId) {
        this.publish_clientId = publish_clientId;
    }

    public String getSubscribe_clientId() {
        return subscribe_clientId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDefault_topic() {
        return default_topic;
    }

    public void setDefault_topic(String default_topic) {
        this.default_topic = default_topic;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    public int getKeepalive() {
        return keepalive;
    }

    public void setKeepalive(int keepalive) {
        this.keepalive = keepalive;
    }

    public int getConnectionTimeout() {
        return connectionTimeout;
    }

    public void setConnectionTimeout(int connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }

    public boolean isCleansession() {
        return cleansession;
    }

    public void setCleansession(boolean cleansession) {
        this.cleansession = cleansession;
    }
}